if (typeof T === 'undefined') require('../setup');

T('ln', function () {

  function t(n, expected, sd) {
    Decimal.precision = sd;
    T.assertEqual(expected, new Decimal(n).ln().valueOf());
  }

  Decimal.config({
    precision: 40,
    rounding: 4,
    toExpNeg: -9e15,
    toExpPos: 9e15
  });

  t('91247532.65728', '18.3290865106890306', 19);
  t('390145000.967298821818782016684792033527978825236257109725032636684195216173865101534596314015627154955417417356051726409514707961291776124601310897', '19.782029025340505793950028597475307602798983116', 47);
  t('1582186416.193367134722504736788921341001732540902935815137028669849087377143230724513115136185091885228053584573993361147951779854091136019178181014965525402328169438038737972227467851264', '21.18207353512', 13);
  t('524656579.6561082202986522788989992058097028959478133491616251386650273315481201712733337497961653741466850177948', '20.07825447252854998238544895', 28);

  // 0.00000000000000000000000000000000000000000000000000012300000000007559999999999999999999999999999999999999243549999999070119999999714232000000000000000000000062028900000114375240000070298928000014402707200950...
  t('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.000000000000000000000000000000000000000000000000000123', 3);
  t('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.000000000000000000000000000000000000000000000000000123', 3);
  t('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.0000000000000000000000000000000000000000000000000001230000000000755', 16);
  t('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.00000000000000000000000000000000000000000000000000012300000000007559', 17);
  t('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.00000000000000000000000000000000000000000000000000012300000000007559999999999999999999999999999999999999243549999999070119999999714232', 83);

  // 0.000000001229999999999549999690409...
  t('1.000000001230000000756', '0.00000000122', 3);
  t('1.000000001230000000756', '0.00000000122999', 6);
  t('1.000000001230000000756', '0.00000000122999999999954', 15);

  t('8.1', '2.09186', 6);
  t('40.34', '3.6973435', 8);
  t('4.2', '1.4350845', 8);
  t('14.23', '2.65535', 6);
  t('21.41', '3.06', 3);
  t('22.67', '3.121', 4);
  t('39.1', '3.666122466', 10);

  t('484260633.26', '19.9981', 6);
  t('236924096.650141980105861288', '19.2832503', 9);
  t('11138070.731145', '16.225879593546584', 17);
  t('316912316.269705411968295', '19.57413568875', 13);
  t('14302.00090090005', '9.5681547295995328150820246661661705098', 38);
  t('11275.000001000060000080002000020000001000000000000005', '9.330343164459576214650017260944374', 34);
  t('27341.0000008', '10.2161426860830683625276502597036387295831', 42);
  t('16240.999999', '9.695294188113030278102040381421186919123', 40);
  t('14805.999994993999999999994994999999999799999999999299999999999', '9.602787782664937484827890675974506248220680541057', 49);
  t('0.979999999999999999', '-0.02020270731751944942845346428', 28);
  t('0.000704006', '-7.25872367911527720999907560001613988913676912731866147366599498415', 66);
  t('2.5', '0.91', 2);
  t('2.0', '0.693147180559945', 15);
  t('0.013440860215', '-4.3094559418430461815', 20);
  t('70.0', '4.248495242', 11);
  t('59.8', '4.091005660956586', 16);
  t('60.0', '4.09', 3);
  t('0.99999999999999999999999999999999999999999999999999985408483944', '-0.00000000000000000000000000000000000000000000000000014591516056', 35);
  t('1.0000000000000000000278495935577735173108449580311901557454985107031530689779032404701969152386509968231412912032547047938976884258008764161145204', '0.000000000000000000027849', 5);
  t('0.99999999999999999999999999999999999977092768577305435532481001390241851854279230037455', '-0.000000000000000000000000000000000000229072314226945644675189986097581481', 36);
  t('0.99999999999999999999999999999999999999999999999999998835768423821199588003439629108184316187951135202946432288978839496371393350180031770629223550075209192125418982248995945098956877584132', '-0.00000000000000000000000000000000000000000000000000001164231576178800411996', 22);

  Decimal.toExpNeg = Decimal.toExpPos = 0;

  t('86581147739152189809997746256.485303', '6.6630879609165666865732779356483110831e+1', 39);
  t('2.49662549037205161930152513676222984332E-1769526964968889', '-4.074486411188359782e+15', 19);
  t('4.75511906567739510224E+9281276469', '2.1370928843035034699971447557867150369194e+10', 41);
  t('8.69428902381899286125995853877646262336481547649342271017E+28073656389526', '6.464198270836177218138049860623405271087114955052778e+13', 52);
  t('6.328946425890222657711855468334E+28226', '6.4994611968630829105921275070197989840133161484e+4', 47);
  t('8.419E-4010970724', '-9.235601395387443688559191477601e+9', 31);
  t('1.7723561424140845E+247846099271', '5.7068673353869932302832431846669628468118839468307384e+11', 53);
  t('4.432834164971387041E-4507057882525783', '-1e+16', 2);
  t('5.6180796113670596347965219927087524242601615E+3880377312075', '8.93489895397792489522883676797722624255e+12', 39);
  t('8.6184097550403752866225958864653E-99458373', '-2.29011364889340897937584119444696367e+8', 36);
  t('7.21733459581750946992541376472150E+771894752', '1.7773533512920215e+9', 17);
  t('7.29846078607878771302050492452384424889888683E-537191033751', '-1.236928066403126e+12', 16);
  t('3.668100638398885156015068016729087120382965349467E+84070728', '1.935800063496311111975e+8', 22);
  t('7.8060858E-167062888423895', '-3.8467651647738609186703184862365050751052e+14', 41);
  t('5.77970666253418116761098030625E+223072047', '5.13642371840220060515235912414184521974662502e+8', 47);
  t('54.944027854626073894087463822117107421615', '4e+0', 2);
  t('5.89E+4068309134235820', '9.36762796618291285378e+15', 21);
  t('6.806688317295882211444994250555E+7553266453', '1.73920387400077162987035162411978513704566862686e+10', 48);
  t('8.7301419368711031383740359E+35766359667870', '8.235508660190309563654957418152355352e+13', 37);
  t('7.926192471441099330397999580E-784167', '-1.80560917444508379549407756805599569268569223e+6', 45);
  t('72.7973', '4.287678866602e+0', 13);
  t('7E+2084142509237', '4.79891547344626727113852205192e+12', 30);
  t('9.3160920091238143684430426114185923861195316789176E+9009721765428', '2.0745e+13', 5);
  t('7.11299819E+7082753304', '1.63e+10', 3);
  t('1.259774278348886756714714853102551787716753309044316124949E+712621', '1.6408707224870705769939774744309009702195e+6', 41);
  t('3.59522279140903230506716479623E+86968785461810', '2.002530289601622667750807006104599119026e+14', 40);
  t('4.19231E-7592313503421', '-1.748194789431315881762449482356139169e+13', 37);
  t('64572.983932271806289465556', '1.10755513969156443144229910347268775332908e+1', 42);
  t('4.961229890606203486886459941941277127027E+604148', '1.39110378041583852706104753424975e+6', 33);
  t('4.1590152196231371771711659246E+403232512853795', '9.284771731076797069605043792598349156233286259e+14', 46);
  t('7.57895891043427E+89609785', '2.0633415715277728333795242903376837197944185472408033310945e+8', 59);
  t('9.9940433950867406385462586629E+57', '1.33549339555687132737e+2', 21);
  t('5.2273640460183882551198285667311888762451852768642903877382E+86461', '1.99085e+5', 6);
  t('8.37869137029350445E+900', '2.07445227543587787134124946870990167444156501037595873e+3', 54);
  t('7E+5', '1.3458835614025541e+1', 17);
  t('8.36991087473514132639620816460727714124539564560E+114871900769', '2.64502326e+11', 9);
  t('88.7213950103796184597368396487398', '4.4855e+0', 5);
});
